package me.vudu.Conflict.Runnables;

import me.vudu.Conflict.ConflictPlugin;
import org.getspout.spoutapi.player.SpoutPlayer;

/**
 * triggert automatisches Hungern
 * @author vwendel
 *
 */
public class HungerTimerRunnable implements Runnable{
	
	private long ticks=0;
	
	@Override
	public void run() {
		  for(SpoutPlayer p: ConflictPlugin.players){
			  
			  this.ticks = p.getWorld().getFullTime()-ConflictPlugin.hungerStartTime;
			  
			  if(ticks > ConflictPlugin.hungerDelayTicks){
				  return;
			  }
			  
			  long rest = ConflictPlugin.hungerDelayTicks-ticks; //verbleibende ticks
			  rest = rest/20; //in sec
			  rest = rest/60; //in min
			  rest++;//Rundungsfehler ausgleichen
	    	  
			  p.sendMessage("Automatischer Hunger-Effekt startet in " +rest+" Minuten!");
			  p.sendMessage("Doppelter Hunger-Effekt, solange keine Basis errichtet!");
			  
			  
	       }
	}

}